function showValue(newValue) {
	document.getElementById("range").innerHTML = newValue+"Km";
}
function showValue1(newValue) {
	document.getElementById("range1").innerHTML = newValue+"Km";
}
function findCGUsers(form) {

	var startRadius = document.getElementById("range").innerHTML;
	
	
	var endRadius = document.getElementById("range1").innerHTML;
	
	
	var cityDD = form.cityDropdownPick.value;
	
	// var e = document.getElementById("radiusDropdown");
//	var radius = form.radiusDropdown.value;
//	var radiusDest = form.radiusDropdownDest.value;

	// var radius = e.options[e.selectedIndex].text;

	var startDate = form.demo1.value;
	var endDate = form.demo2.value;
	var cbResults = null;

	var radioResults = 'Radio buttons: ';
	for ( var i = 0; i < form.elements.length; i++) {
		if (form.elements[i].type == 'checkbox') {
			if (form.elements[i].checked == true) {
				cbResults += form.elements[i].value + ' ';
			}
		}
		if (form.elements[i].type == 'radio') {
			if (form.elements[i].checked == true) {
				radioResults += form.elements[i].value + ' ';
			}
		}

	}

//local host use - change to server code
	
	

//
//location.href = "/SocialCommuting/GetCGUsers?startDate=" + startDate
//+ "&endDate=" + endDate + "&checkBoxVal=" + cbResults
//+ "&startRadius=" + startRadius + "&endRadius=" + endRadius + "&slat="
//+ $('#input-slat').val() + "&slng=" + $('#input-slng').val()
//+ "&elat=" + $('#input-slat').val() + "&elng="
//+ $('#input-slng').val();
//	
	
	location.href = "/it/GetCGUsers?startDate=" + startDate
	+ "&endDate=" + endDate + "&checkBoxVal=" + cbResults
	+ "&startRadius=" + startRadius + "&endRadius=" + endRadius + "&slat="
	+ $('#input-slat').val() + "&slng=" + $('#input-slng').val()
	+ "&elat=" + $('#input-slat').val() + "&elng="
	+ $('#input-slng').val()
	+"&cityVal="+cityDD;
}
$(document).ready(function() {
	initialize();

});

var map;
function initialize() {

	var myLatlng;
	//gothenburg center
	var myOptions1 = {
		center : new google.maps.LatLng(57.70779280783442, 11.937975883483887),
		zoom : 12,
		mapTypeId : google.maps.MapTypeId.ROADMAP
	};
	//gothenburg center
	var myOptions2 = {
		center : new google.maps.LatLng(19.429413676234212, -99.12683863302618),
		zoom : 12,
		mapTypeId : google.maps.MapTypeId.ROADMAP
	};

	$("#cityDropdownPick").change(function () {
		$("select option:selected").each(function () {
			if ($('#cityDropdownPick').val() == "gothenborg") {
				map = new google.maps.Map(document.getElementById("map_canvas"),myOptions1);
				myLatlng = new google.maps.LatLng(57.70779280783442, 11.937975883483887);
				var marker = new google.maps.Marker({
					position : myLatlng,
					map : map,
					title : "Your Location"
				});
				marker.setMap(map);

				var infoWindow = new google.maps.InfoWindow();

				google.maps.event.addListener(map, 'click',
						function(event) {

							var html = 'The LatLng value is: ' + event.latLng
									+ ' at zoom level ' + map.getZoom();
							infoWindow.setContent(html);
							infoWindow.setPosition(event.latLng);

							if ($('#input-slat').val() == ""
									&& $('#input-elat').val() == "") {
								$('#input-slat').val(event.latLng.lat());
								$('#input-slng').val(event.latLng.lng());
							} else if ($('#input-slat').val() != ""
									&& $('#input-elat').val() == "") {
								$('#input-elat').val(event.latLng.lat());
								$('#input-elng').val(event.latLng.lng());
							} else if ($('#input-slat').val() != ""
									&& $('#input-elat').val() != "") {
								$('#input-slat').val('');
								$('#input-slng').val('');
								$('#input-elat').val('');
								$('#input-elng').val('');
								$('#input-slat').val(event.latLng.lat());
								$('#input-slng').val(event.latLng.lng());
							}
							
							infoWindow.open(map);
						});
				// javascript:void(prompt('',gApplication.getMap().getCenter()));
				javascript: void (prompt('', gApplication.getMap().getCenter()));
			} else if ($('#cityDropdownPick').val() == "mexico") {
				map = new google.maps.Map(document.getElementById("map_canvas"),
						myOptions2);
				myLatlng = new google.maps.LatLng(19.429413676234212, -99.12683863302618);
				var marker = new google.maps.Marker({
					position : myLatlng,
					map : map,
					title : "Your Location"
				});
				marker.setMap(map);

				var infoWindow = new google.maps.InfoWindow();

				google.maps.event.addListener(map, 'click',
						function(event) {

							var html = 'The LatLng value is: ' + event.latLng
									+ ' at zoom level ' + map.getZoom();
							infoWindow.setContent(html);
							infoWindow.setPosition(event.latLng);

							if ($('#input-slat').val() == ""
									&& $('#input-elat').val() == "") {
								$('#input-slat').val(event.latLng.lat());
								$('#input-slng').val(event.latLng.lng());
							} else if ($('#input-slat').val() != ""
									&& $('#input-elat').val() == "") {
								$('#input-elat').val(event.latLng.lat());
								$('#input-elng').val(event.latLng.lng());
							} else if ($('#input-slat').val() != ""
									&& $('#input-elat').val() != "") {
								$('#input-slat').val('');
								$('#input-slng').val('');
								$('#input-elat').val('');
								$('#input-elng').val('');
								$('#input-slat').val(event.latLng.lat());
								$('#input-slng').val(event.latLng.lng());
							}
							
							infoWindow.open(map);
						});
				javascript: void (prompt('', gApplication.getMap().getCenter()));
			}
          });
	  }).change();
	
}

function newSearch(){
	 
//	 location.href = "/SocialCommuting/WelcomeServlet";
	
	location.href = "/it/WelcomeServlet";
}


